home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / gui / gtlayout.lha / Source / LT_DeleteHandle.c < prev    next >
C/C++ Source or Header  |  1998-09-09  |  5KB  |  241 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. #ifdef DO_BOOPSI_KIND    /* Support code */
  17. STATIC VOID
  18. LTP_BOOPSI_Cleanup(ObjectNode *group)
  19. {
  20.     ObjectNode *node;
  21.  
  22.     SCANGROUP(group,node)
  23.     {
  24.         switch(node->Type)
  25.         {
  26.             case BOOPSI_KIND:
  27.  
  28.                 DB(kprintf("2) disposing boopsi object\n"));
  29.  
  30.                 CloseLibrary(node->Special.BOOPSI.ClassBase);
  31.                 node->Special.BOOPSI.ClassBase = NULL;
  32.  
  33.                 FreeTagItems(node->Special.BOOPSI.ClassTags);
  34.                 node->Special.BOOPSI.ClassTags = NULL;
  35.  
  36.                 break;
  37.  
  38.             case GROUP_KIND:
  39.  
  40.                 LTP_BOOPSI_Cleanup(node);
  41.                 break;
  42.         }
  43.     }
  44. }
  45. #endif /* DO_BOOPSI_KIND */
  46.  
  47. VOID
  48. LTP_DisposeGadgets(struct LayoutHandle *Handle)
  49. {
  50.     if(Handle->List)
  51.     {
  52.         struct Gadget    *Gadget;
  53.         ObjectNode        *Node;
  54.  
  55.         LTP_StripGadgets(Handle,Handle->List);
  56.  
  57.         Gadget = Handle->List;
  58.  
  59.         if(Handle->ExitFlush)
  60.         {
  61.             while(Gadget)
  62.             {
  63.                 if(GETOBJECT(Gadget,Node))
  64.                 {
  65.                     LTP_PutStorage(Node);
  66.  
  67.                     LTP_DeleteObjectNode(Handle,Node);
  68.                 }
  69.  
  70.                 Gadget = Gadget->NextGadget;
  71.             }
  72.         }
  73.         else
  74.         {
  75.             while(Gadget)
  76.             {
  77.                 if(GETOBJECT(Gadget,Node))
  78.                     LTP_DeleteObjectNode(Handle,Node);
  79.  
  80.                 Gadget = Gadget->NextGadget;
  81.             }
  82.         }
  83.  
  84.         FreeGadgets(Handle->List);
  85.  
  86.         Handle->List = NULL;
  87.     }
  88.  
  89.     #ifdef DO_BOOPSI_KIND
  90.     {
  91.         if(Handle->BOOPSIList)
  92.         {
  93.             struct Gadget *gadget = (struct Gadget *)Handle->BOOPSIList,*next;
  94.             ObjectNode *Node;
  95.  
  96.             LTP_StripGadgets(Handle,(struct Gadget *)Handle->BOOPSIList);
  97.  
  98.             while(gadget)
  99.             {
  100.                 next = gadget->NextGadget;
  101.  
  102.                 if(GETOBJECT(gadget,Node))
  103.                 {
  104.                     DB(kprintf("1) disposing boopsi object\n"));
  105.  
  106.                     DisposeObject(gadget);
  107.                     Node->Host = NULL;
  108.                 }
  109.  
  110.                 gadget = next;
  111.             }
  112.  
  113.             Handle->BOOPSIList = NULL;
  114.             Handle->BOOPSIPrevious = NULL;
  115.         }
  116.  
  117.             // Clean up all BOOPSI objects. This includes even those
  118.             // which have never been displayed.
  119.  
  120.         LTP_BOOPSI_Cleanup(Handle->TopGroup);
  121.     }
  122.     #endif    /* DO_BOOPSI_KIND */
  123. }
  124.  
  125.  
  126. /*****************************************************************************/
  127.  
  128.  
  129. /****** gtlayout.library/LT_DeleteHandle ******************************************
  130. *
  131. *   NAME
  132. *    LT_DeleteHandle -- Release storage space allocated by
  133. *                       LT_CreateHandleTagList, closing windows,
  134. *                       removing gadgets, etc.
  135. *
  136. *   SYNOPSIS
  137. *    LT_DeleteHandle(Handle);
  138. *                      A0
  139. *
  140. *    VOID LT_DeleteHandle(LayoutHandle *);
  141. *
  142. *   FUNCTION
  143. *    Windows and gadgets created by LT_CreateHandleTagList()
  144. *    are removed, any associated memory is deallocated.
  145. *
  146. *   INPUTS
  147. *    Handle - Pointer to a LayoutHandle structure created
  148. *        by LT_CreateHandleTaglist(). Passing NULL is
  149. *        harmless.
  150. *
  151. *   RESULT
  152. *    none
  153. *
  154. *   SEE ALSO
  155. *    gtlayout.library/CreateHandleTagList
  156. *
  157. ******************************************************************************
  158. *
  159. */
  160.  
  161. VOID LIBENT
  162. LT_DeleteHandle(REG(a0) LayoutHandle *Handle)
  163. {
  164.     if(Handle)
  165.     {
  166.         if(Handle->UnlockPubScreen)
  167.             UnlockPubScreen(NULL,Handle->PubScreen);
  168.  
  169.         #ifdef DO_CLONING
  170.         {
  171.             if(Handle->CloneExtra && Handle->CloneExtra->Screen)
  172.                 ScreenToBack(Handle->CloneExtra->Screen);
  173.         }
  174.         #endif
  175.  
  176.         LTP_DisposeGadgets(Handle);
  177.  
  178.         LT_UnlockWindow(Handle->Parent);
  179.  
  180.         if(Handle->Window)
  181.         {
  182.             LT_DeleteWindowLock(Handle->Window);
  183.  
  184.             if(Handle->MsgPort && Handle->Window->UserPort)
  185.             {
  186.                 struct IntuiMessage    *intuiMsg;
  187.                 struct Node            *next;
  188.  
  189.                 Forbid();
  190.  
  191.                 for(intuiMsg = (struct IntuiMessage *)Handle->Window->UserPort->mp_MsgList.lh_Head ; next = intuiMsg->ExecMessage.mn_Node.ln_Succ ; intuiMsg = (struct IntuiMessage *)next)
  192.                 {
  193.                     if(intuiMsg->IDCMPWindow == Handle->Window)
  194.                     {
  195.                         Remove(intuiMsg);
  196.  
  197.                         ReplyMsg(intuiMsg);
  198.                     }
  199.                 }
  200.  
  201.                 Handle->Window->UserPort = NULL;
  202.  
  203.                 ModifyIDCMP(Handle->Window,NULL);
  204.  
  205.                 Permit();
  206.             }
  207.  
  208.             ClearMenuStrip(Handle->Window);
  209.             CloseWindow(Handle->Window);
  210.         }
  211.  
  212.         #ifdef DO_MENUS
  213.         {
  214.             LT_DisposeMenu(Handle->Menu);
  215.         }
  216.         #endif    // DO_MENUS
  217.  
  218.         DisposeObject(Handle->AmigaGlyph);
  219.         DisposeObject(Handle->CheckGlyph);
  220.  
  221.         FreeScreenDrawInfo(Handle->Screen,Handle->DrawInfo);
  222.  
  223.         FreeVisualInfo(Handle->VisualInfo);
  224.  
  225.         DisposeObject(Handle->BevelImage);
  226.         DisposeObject(Handle->GrooveImage);
  227.  
  228.         if(Handle->RPort.Font && Handle->CloseFont)
  229.             CloseFont(Handle->RPort.Font);
  230.  
  231.         #ifdef DO_CLONING
  232.         {
  233.             if(Handle->CloneExtra && Handle->CloneExtra->Screen)
  234.                 CloseScreen(Handle->CloneExtra->Screen);
  235.         }
  236.         #endif
  237.  
  238.         AsmDeletePool(Handle->Pool,SysBase);
  239.     }
  240. }
  241.